home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_StoredProcedures_VBScript.asp < prev    next >
Encoding:
Text File  |  1999-06-03  |  1.6 KB  |  64 lines

  1. <%     @ LANGUAGE="VBSCRIPT"         %>
  2. <%    Option Explicit                %>
  3.  
  4. <!--METADATA TYPE="typelib" 
  5. uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
  6. <%    ' This example can be used to call the ByRoyalty stored procedure 
  7.     ' installed with the PUBS database with Microsoft SQL Server.
  8.  
  9.     ' This sample assumes that SQL Server is running on the local machine
  10. %>
  11.  
  12.  
  13. <HTML>
  14.     <HEAD>
  15.         <TITLE>Using Stored Procedures</TITLE>
  16.     </HEAD>
  17.  
  18.     <BODY bgcolor="white" topmargin="10" leftmargin="10">
  19.         
  20.         <!-- Display Header -->
  21.  
  22.         <font size="4" face="Arial, Helvetica">
  23.         <b>Using Stored Procedures</b></font><p>   
  24.  
  25.         <%
  26.             Dim oConn    
  27.             Dim strConn    
  28.             Dim oCmd    
  29.             Dim oRs        
  30.  
  31.             Set oConn = Server.CreateObject("ADODB.Connection")
  32.             Set oCmd = Server.CreateObject("ADODB.Command")
  33.  
  34.             
  35.             ' Open ADO Connection using account "sa"
  36.             ' and blank password
  37.              
  38.             strConn="Provider=SQLOLEDB;User ID=sa;Initial Catalog=pubs;Data Source="& Request.ServerVariables("SERVER_NAME")
  39.             oConn.Open strConn
  40.             Set oCmd.ActiveConnection = oConn
  41.  
  42.  
  43.             ' Setup Call to Stored Procedure and append parameters
  44.  
  45.             oCmd.CommandText = "{call byroyalty(?)}"
  46.             oCmd.Parameters.Append oCmd.CreateParameter("@Percentage", adInteger, adParamInput)
  47.  
  48.             
  49.             ' Assign value to input parameter
  50.  
  51.             oCmd("@Percentage") = 75
  52.  
  53.  
  54.             ' Fire the Stored Proc and assign resulting recordset
  55.             ' to our previously created object variable
  56.                     
  57.             Set oRs = oCmd.Execute            
  58.         %>
  59.  
  60.         Author ID = <% Response.Write oRs("au_id") %><BR>
  61.  
  62.     </BODY>
  63. </HTML>
  64.